#!/bin/bash

date=$(date +%y%m%d)
top_name=$1

ftype="OASIS"
path="/projects.SE024/cascade/workspace/xjsun/PV/DRC/result"

if echo ${top_name} | grep -q "oasis"; then
    echo "this is OASIS file path!!"
    oasis_file=${top_name}
    ftype="OASIS"
elif echo ${top_name} | grep -q "gds"; then
    echo "this is GDSII file path!!"
    oasis_file=${top_name}
    ftype="GDSII"
else
    echo "this is top name!!"
    oasis_file="/projects.SE024/cascade/workspace/xjsun/${top_name}/post.${date}/dataout/${top_name}.strm.${date}.oasis"
fi

#### GDS 太大 容易出问题
oasis_top_name=`exec drvTopcell ${oasis_file}`

cd ${path}

power="'VDDC'"
ground="'GNDC'"

echo "LAYOUT PATH '${oasis_file}'"      >  ${path}/DRC.cal
echo "LAYOUT SYSTEM ${ftype}"              >> ${path}/DRC.cal
echo "LAYOUT PRIMARY ${oasis_top_name}" >> ${path}/DRC.cal
echo "VARIABLE POWER_NAME ${power}"       >> ${path}/DRC.cal
echo "VARIABLE GROUND_NAME ${ground}"      >> ${path}/DRC.cal
echo "INCLUDE ${path}/drc.rul"        >> ${path}/DRC.cal

/apps/mentor/aoi_cal_2021.2_28.15/bin/calibre -drc -hier -hyper -turbo 32 ${path}/DRC.cal | tee DRC.log